package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.entity.Category;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author iTaotao
 * @date 2023/7/25 17:36
 * @desciption: 分类查询接口
 */
@Mapper
public interface CategoryMapper {

    Page<Category> seletePage(String name, String type);

    /**
     * 添加类别
     *
     * @param category 类别
     */
    @AutoFill(OperationType.INSERT)
    void addCategory(Category category);

    /**
     * 删除类别id
     *
     * @param id id
     */
    @Delete("delete from category where id = #{id}")
    void deleteCategoryById(String id);

    /**
     * 更新类别id
     *
     * @param category 类别
     */
    @AutoFill(OperationType.UPDATE)
    void updateCategoryById(Category category);

    @AutoFill(OperationType.UPDATE)
    void updateStatusById(Category category);

    @Select("select * from category where type = #{type}")
    List<Category> selectCategoryByType(Integer type);
}
